package com.AFH.test;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;

public class BitmapManager{
	private static Bitmap[] welcomeResource;
	private static Bitmap[] monsterResource;
	private static Bitmap[] backgroundResource;
	private static Bitmap[] TowerResource;
	private static Bitmap[] AttackResource;
	private static Bitmap[] GameUIResource;
	
	private static int[][] aniDefTower[][];
	private static int[][] aniOffTower[][];
	private BitmapManager(){
		//��
	}
	public static void LoadWelcomeResource(Resources r){
		welcomeResource = new Bitmap[15];
		welcomeResource[0]= BitmapFactory.decodeResource(r, R.drawable.gamewelcomepre);
		welcomeResource[1]= BitmapFactory.decodeResource(r, R.drawable.text_invation);
		welcomeResource[2]= BitmapFactory.decodeResource(r, R.drawable.text_from);
		welcomeResource[3]= BitmapFactory.decodeResource(r, R.drawable.text_hell);
		welcomeResource[4]= BitmapFactory.decodeResource(r, R.drawable.text_the);
		welcomeResource[5]= BitmapFactory.decodeResource(r, R.drawable.play_nottouched);
		welcomeResource[6]= BitmapFactory.decodeResource(r, R.drawable.soundon);
		welcomeResource[7]= BitmapFactory.decodeResource(r, R.drawable.soundoff);
		welcomeResource[8]= BitmapFactory.decodeResource(r, R.drawable.quit_nottouched);
		welcomeResource[9]= BitmapFactory.decodeResource(r, R.drawable.play_selected);
		welcomeResource[10]= BitmapFactory.decodeResource(r, R.drawable.quit_selected);
		welcomeResource[11]=BitmapFactory.decodeResource(r,R.drawable.about);
		
		

			
	}
	public static void LoadGameUIResource(Resources r){
		GameUIResource = new Bitmap[100];
		GameUIResource[0] = BitmapFactory.decodeResource(r, R.drawable.bomb1);
		GameUIResource[1] = BitmapFactory.decodeResource(r, R.drawable.tnt);
		GameUIResource[2] = BitmapFactory.decodeResource(r, R.drawable.buildmenu);
		GameUIResource[3] = BitmapFactory.decodeResource(r, R.drawable.selected);
		GameUIResource[4] = BitmapFactory.decodeResource(r, R.drawable.money);
		//bomb boom
		GameUIResource[10] = BitmapFactory.decodeResource(r, R.drawable.boom1);
		GameUIResource[11] = BitmapFactory.decodeResource(r, R.drawable.boom2);
		GameUIResource[12] = BitmapFactory.decodeResource(r, R.drawable.boom3);
		GameUIResource[13] = BitmapFactory.decodeResource(r, R.drawable.boom4);
		//surprise box
		GameUIResource[8] = BitmapFactory.decodeResource(r, R.drawable.surprise);
		GameUIResource[9] = BitmapFactory.decodeResource(r, R.drawable.surprise1);
		//game over
		GameUIResource[30] = BitmapFactory.decodeResource(r, R.drawable.gamelost);
		//menu
		GameUIResource[20] = BitmapFactory.decodeResource(r, R.drawable.menu);
	}
	public static void LoadTowerResource(Resources r){
		TowerResource = new Bitmap[100];
		//fire tower
		TowerResource[0] = BitmapFactory.decodeResource(r, R.drawable.firetower1);
		TowerResource[1] = BitmapFactory.decodeResource(r, R.drawable.firetower1attack1);
		TowerResource[2] = BitmapFactory.decodeResource(r, R.drawable.firetower1attack2);
		TowerResource[5] = BitmapFactory.decodeResource(r, R.drawable.firetower1attack1_selected);
		//earth tower
		TowerResource[3] = BitmapFactory.decodeResource(r, R.drawable.earthtower);
		TowerResource[8] = BitmapFactory.decodeResource(r, R.drawable.earthtower_selected);
		//build tower menu
		
		TowerResource[4] = BitmapFactory.decodeResource(r, R.drawable.endbuild);
		
		//nature tower
		TowerResource[11]= BitmapFactory.decodeResource(r, R.drawable.nature);
		TowerResource[12]= BitmapFactory.decodeResource(r, R.drawable.nature1);
		TowerResource[13]= BitmapFactory.decodeResource(r, R.drawable.nature2);
		TowerResource[14]= BitmapFactory.decodeResource(r, R.drawable.nature3);
		TowerResource[15] = BitmapFactory.decodeResource(r, R.drawable.nature_selected);
		
		//thunder tower
		TowerResource[21]= BitmapFactory.decodeResource(r, R.drawable.thunder);
		TowerResource[22]= BitmapFactory.decodeResource(r, R.drawable.thunder1);
		TowerResource[23]= BitmapFactory.decodeResource(r, R.drawable.thunder2);
		TowerResource[24]= BitmapFactory.decodeResource(r, R.drawable.thunder3);
		TowerResource[25]= BitmapFactory.decodeResource(r, R.drawable.thunder_selected);
		//null
		TowerResource[99]= null;
	}
	public static void LoadbackgroundResource(Resources r){
		backgroundResource = new Bitmap[4];
		backgroundResource[0]= BitmapFactory.decodeResource(r, R.drawable.hellbk);
		backgroundResource[1]= BitmapFactory.decodeResource(r, R.drawable.buildmenu);
		backgroundResource[2]= BitmapFactory.decodeResource(r, R.drawable.selected);
		backgroundResource[3]= BitmapFactory.decodeResource(r, R.drawable.aboutus);
	}
	
	public static void LoadAttackResource(Resources r){
		AttackResource = new Bitmap[100];
		//fire attack
		AttackResource[0]= BitmapFactory.decodeResource(r, R.drawable.attackfire);
		AttackResource[1]= BitmapFactory.decodeResource(r, R.drawable.attackfire2);
		AttackResource[2]= BitmapFactory.decodeResource(r, R.drawable.attackfire3);
		//thunder attack
		AttackResource[11]= BitmapFactory.decodeResource(r, R.drawable.thunderattack1);
		AttackResource[12]= BitmapFactory.decodeResource(r, R.drawable.thunderattack2);
		AttackResource[13]= BitmapFactory.decodeResource(r, R.drawable.thunderattack3);
		//nature attack
		AttackResource[21]= BitmapFactory.decodeResource(r, R.drawable.natureattack1);
		AttackResource[22]= BitmapFactory.decodeResource(r, R.drawable.natureattack2);
		AttackResource[23]= BitmapFactory.decodeResource(r, R.drawable.natureattack3);
		//monster attack
		AttackResource[3]= BitmapFactory.decodeResource(r, R.drawable.monsterattack1);
		AttackResource[4]= BitmapFactory.decodeResource(r, R.drawable.monsterattack2);
		AttackResource[5]= BitmapFactory.decodeResource(r, R.drawable.monsterattack3);
		AttackResource[6]= BitmapFactory.decodeResource(r, R.drawable.monsterattack4);
		AttackResource[7]= BitmapFactory.decodeResource(r, R.drawable.monsterattack5);
		AttackResource[8]= BitmapFactory.decodeResource(r, R.drawable.monsterattack6);
		AttackResource[9]= BitmapFactory.decodeResource(r, R.drawable.monsterattack7);
		AttackResource[10]= BitmapFactory.decodeResource(r, R.drawable.monsterattack8);
		
		AttackResource[99]=null;
	}

	public static void LoadMonsterResource(Resources r){
		monsterResource=new Bitmap[100];
		//Monster Move
		monsterResource[0]=BitmapFactory.decodeResource(r, R.drawable.monstera1);
		monsterResource[1]=BitmapFactory.decodeResource(r, R.drawable.monstera2);
		monsterResource[2]=BitmapFactory.decodeResource(r, R.drawable.monstera3);
		monsterResource[3]=BitmapFactory.decodeResource(r, R.drawable.monstera4);
		// MonsterB move
		monsterResource[21]= BitmapFactory.decodeResource(r, R.drawable.monsterb1);
		monsterResource[22]= BitmapFactory.decodeResource(r, R.drawable.monsterb2);
		monsterResource[23]= BitmapFactory.decodeResource(r, R.drawable.monsterb3);
		//Boss move
		monsterResource[31]= BitmapFactory.decodeResource(r, R.drawable.boss1);
		monsterResource[32]= BitmapFactory.decodeResource(r, R.drawable.boss2);
		monsterResource[33]= BitmapFactory.decodeResource(r, R.drawable.boss3);
		monsterResource[34]= BitmapFactory.decodeResource(r, R.drawable.boss4);
		
		
	
		//Monster Disappear
		monsterResource[11]=BitmapFactory.decodeResource(r, R.drawable.monsteradie1);
		monsterResource[12]=BitmapFactory.decodeResource(r, R.drawable.monsteradie2);
		monsterResource[13]=BitmapFactory.decodeResource(r, R.drawable.monsteradie3);
		monsterResource[14]=BitmapFactory.decodeResource(r, R.drawable.monsteradie4);
		//Monster Nothing
		monsterResource[99]=null;
	}
	public static void DrawGameUIResource(int ImgIndex,Canvas canvas,float x,float y,Paint paint){
		canvas.drawBitmap(GameUIResource[ImgIndex], x, y, paint);
	}
	
	
	public static void DrawbackgroundResource(int ImgIndex,Canvas canvas,float x,float y,Paint paint){
		canvas.drawBitmap(backgroundResource[ImgIndex], x, y, paint);
	}
	public static void DrawWelcomeResource(int ImgIndex,Canvas canvas,float x,float y,Paint paint){
		canvas.drawBitmap(welcomeResource[ImgIndex], x, y, paint);

	}
	public static void DrawAttackResource(int ImgIndex,Canvas canvas,float x,float y,Paint paint){
		canvas.drawBitmap(AttackResource[ImgIndex], x, y, paint);
	}

	public static void DrawTower(int ImgIndex,Canvas canvas,float x,float y,Paint paint){
		canvas.drawBitmap(TowerResource[ImgIndex], x, y, paint);
	}
	public static void DrawMonster(int ImgIndex,Canvas canvas,float x,float y,Paint paint){
		canvas.drawBitmap(monsterResource[ImgIndex], x, y, paint);
	}
	public static int[][] getAniDefTower(int att1,int att2){
		return aniDefTower[att1][att2];
	}
	public static int[][] getAniOffTower(int att1,int att2){
		return aniOffTower[att1][att2];
	}
	public static int[][] getAttackAni(int att){
		switch(att){
		case GameData.FIRETOWER:
			return GameData.TOWERFIREATTACK;
		case GameData.THUNDERTOWER:
			return GameData.TOWERTHUNDERATTACK;
		case GameData.NATURETOWER:
			return GameData.TOWERNATUREATTACK;
		
		}
		
		return null;
	}
}